package code.easylevel;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class StackImplementation {

	public static List<String> stackList  = new ArrayList<String>();
	public static void main(String[] args) throws IOException {
		BufferedReader bufferedReader;
		String line;
		File file = new File(args[0]);
		bufferedReader = new BufferedReader(new FileReader(file));
		while((line=bufferedReader.readLine()) != null){
			push(line);
			pop();
			stackList.removeAll(stackList);
		}
		bufferedReader.close();
	}
	
	public static void push(String line){
		String[] inputParams = line.split("\\s");
		for(int i = 0 ;i <inputParams.length ;i++){
			stackList.add((String)inputParams[i]);
		}
	}
	
	public static void pop(){
		for(int i = stackList.size()-1;i>=0;i=i-2 ){
			System.out.print(stackList.get(i)+" ");
		}
		System.out.println("");
	}

}
